/**
 * 伪造数据助手
 */
class EsBogusUtils {
	static enable = true;
	/**
	 * 获取随机微信用户
	 */
	static async getWxUser() {
		const [error, ret] = await uni.request({
			url: 'http://www.byaso.com/index.php/api/bogus/get_wxuser',
		})
		console.log('[Bogus模拟登录] getWxUser ret=', ret.data.data)
		return ret.data.data;
	}
	static async login() {
		if (!EsBogusUtils.enable) {
			console.log('[Bogus模拟登录] 全局关闭')
			return;
		}
		console.log('[Bogus模拟登录] login 开启')
		let wxUser = await EsBogusUtils.getWxUser();
		console.log('[Bogus模拟登录] login wxUser=', wxUser)
		uni.setStorageSync('wx_user', wxUser)
		wxUser.is_bogus = 1;
		wxUser.oaid = uni.getStorageSync('OAID') || '';
		wxUser.android_id = uni.getStorageSync('ANDROID_ID') || '';
		const [error, ret] = await uni.request({
			method: 'POST',
			url: 'http://www.byaso.com/index.php/api/user/wxlogin',
			data: wxUser
		});
		console.log('[Bogus模拟登录] login 发送数据=', wxUser, '接收数据=', ret)
		uni.setStorageSync('user', ret);

	}
}

export default EsBogusUtils;
